<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>文章审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" th:href="@{/static/css/font.css}">
    <link rel="stylesheet" th:href="@{/static/css/xadmin.css}">

    <script th:src="@{/static/js/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/static/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->


    <script type="text/javascript" charset="utf-8" th:src="@{/static/ueditor/ueditor.config.js}"></script>
    <script type="text/javascript" charset="utf-8" th:src="@{/static/ueditor/ueditor.all.js}"> </script>
    <script type="text/javascript" charset="utf-8" th:src="@{/static/ueditor/lang/zh-cn/zh-cn.js}"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div style="" class="layui-form-item">
            <label  class="layui-form-label">
                <input type="hidden"  name="type" value="1"><!--文章-->
            </label>
            <div class="layui-input-inline">
                    <img width="200px" th:src="${article.getLitpic()}" class="layui-upload-img" id="demo">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">
                    <span class="x-red">*</span>资源标题
                </label>
                <div class="layui-input-inline">
                    <input type="text" th:value="${article.getTitle()}" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">
                    <span class="x-red">*</span>所属栏目
                </label>
                <div class="layui-input-inline">
                    <select style="z-index:999;" id="arttypeId" name="arttypeId" class="valid">
                        <option  disabled th:each="arttype:${arttypes}" th:text="${arttype.getTitle()}"  th:selected="${arttype.getActtypeId()==article.getArttypeId()}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">优先级</label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" th:value="${article.getWeight()}" placeholder="排序"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label  class="layui-form-label">
                    点击量
                </label>
                <div class="layui-input-inline">
                    <input type="text"  th:value="${article.getClickcount()}" placeholder="不输入默认1-200随机" name="clickcount"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div th:if="${article.getType()}!=1" class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>资源地址
            </label>
            <div class="layui-input-block">
                <input type="text"  placeholder="请输入有效地址" th:value="${article.getDownloadurl()}" class="layui-input">
            </div>
        </div>
        <div th:if="${article.getType()}!=1" class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>资源密码
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="downloadpassword" th:value="${article.getDownloadpassword()}"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>描述
            </label>
            <div class="layui-input-block">
                <textarea id="descr" th:utext="${article.getDescription()}" name="description" lay-verify="description" placeholder="请输入内容最好不要超过100字" class="layui-textarea"></textarea>
            </div>
        </div>

        <div th:if="${article.getType()}!=2" class="layui-form-item layui-form-text">
            <label  class="layui-form-label">
                文章内容
            </label>
            <div class="layui-input-block">
                <textarea id="context"  th:text="${article.getContext()}" name="context" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标签</label>
            <div class="layui-input-block">
                <input type="checkbox" th:each="tag:${tags}" th:title="${tag.getTitle()}" checked  >
            </div>
        </div>
        <div th:if="${article.getType()}!=1" class="layui-form-item">
            <label class="layui-form-label">所需积分</label>
            <div class="layui-input-inline">
                <select name="jf">
                    <option th:if="${article.getIsFree()}==1"  value="0">免费资源</option>
                    <option th:unless="${article.getIsFree()}==1" th:text="${article.getJf()}" ></option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">评论</label>
            <div class="layui-input-block">
                <input type="checkbox" name="commentState" th:checked="${article.getCommentState()}" value="1" lay-skin="switch" lay-text="允许|禁止">
            </div>
        </div>
        <div th:if="${article.getState()==3}" class="layui-form-item">
            <label class="layui-form-label">驳回内容</label>
            <div class="layui-input-block">
                <textarea  th:text="${article.getResson()}" name="context" class="layui-textarea"></textarea>
            </div>
        </div>
    </form>
        <div th:switch="${article.getState()}" style=" text-align:center; margin:0 auto;">
            <div th:case="0">
            <button  class="layui-btn" onclick="sh(1)" >
                审核通过
            </button>
            <button  class="layui-btn  layui-btn-danger" onclick="sh(2)" >
                未通过
            </button>
            <button  class="layui-btn layui-btn-warm" onclick="bh(3)">
                审核驳回
            </button>
            </div>
            <div th:case="1">
                <button type="button" class="layui-btn layui-btn-disabled">已审核</button>
            </div>
            <div th:case="2">
                <button type="button" class="layui-btn layui-btn-disabled">不通过</button>
            </div>
            <div th:case="3">
                <button type="button" class="layui-btn layui-btn-disabled">已驳回</button>
            </div>
        </div>
</div>
    <script th:inline="javascript">
    layui.use(['form','layer','upload','layedit'], function() {

        var form = layui.form, layer = layui.layer, upload = layui.upload, $ = layui.jquery,layedit = layui.layedit;
        //自定义验证规则
        /*文章layui富文本*/
       layedit.build('descr',{
                tool: ['left', 'center', 'right', '|'],
                height:100,
                uploadImage: {
                    url: '' //接口url
                    ,type: '' //默认post
                }
            }
        )
       layedit.build('context',{
                tool: ['left', 'center', 'right', '|'],

                uploadImage: {
                    url: '' //接口url
                    ,type: '' //默认post
                }
            }
        )


    });
    var id=[[${article.getArId()}]];
     function sh(state){
         layer.msg('你确定审核吗，将不能更改？', {
             time: 0 //不自动关闭
             ,btn: ['必须啊', '再想想']
             ,yes: function(index){
                 $.ajax({
                     url:'/admin/article/shstate',
                     method:"post",
                     dataType:'json',
                     data:{id:id,state:state},
                         success:function (data) {
                         if(data.code==200){
                             layer.close(index);
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             parent.msge(data.msg);

                         }else if(data.code==500){
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             parent.msge(data.msg,{icon: 5});
                         }else if(data.hashMap.code=='999'){
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             layer.msg(data.hashMap.msg);
                         }

                     },error:function () {
                         layer.msg("网络错误", {icon: 5});
                     }
                 })


             }
         });

     }
     
     function bh(state) {
         layer.prompt(
             {
                 formType: 2, //输入框类型，支持0（文本）默认1（密码）2（多行文本）
                 value: '', //初始时的值，默认空字符
                 maxlength: 140, //可输入文本的最大长度，默认500
                 title: '驳回内容',
                 area: ['300px', '180px']
             },
             function(val, index){

                 $.ajax({
                     url:'/admin/article/shstate',
                     method:"post",
                     dataType:'json',
                     data:{id:id,state:state,contxt:val},
                     success:function (data) {
                         if(data.code==200){
                             layer.close(index);
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             parent.msge(data.msg);
                         }else if(data.code==500){
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             parent.msge(data.msg);
                         }else if(data.hashMap.code=='999'){
                             var index = parent.layer.getFrameIndex(window.name);//获取父id
                             parent.layer.close(index);
                             layer.msg(data.hashMap.msg);
                         }

                     },error:function () {
                         layer.msg("网络错误", {icon: 5});
                     }
                 })
         });
     }
</script>
</body>
</html>